﻿namespace UnityEngine
{
    using System;
    using System.Runtime.CompilerServices;

    public sealed class WebCamTexture : Texture
    {
        public WebCamTexture()
        {
            this.Internal_CreateWebCamTexture(string.Empty, 0, 0, 0);
        }

        public WebCamTexture(string deviceName)
        {
            this.Internal_CreateWebCamTexture(deviceName, 0, 0, 0);
        }

        public WebCamTexture(int requestedWidth, int requestedHeight)
        {
            this.Internal_CreateWebCamTexture(string.Empty, requestedWidth, requestedHeight, 0);
        }

        public WebCamTexture(int requestedWidth, int requestedHeight, int requestedFPS)
        {
            this.Internal_CreateWebCamTexture(string.Empty, requestedWidth, requestedHeight, requestedFPS);
        }

        public WebCamTexture(string deviceName, int requestedWidth, int requestedHeight)
        {
            this.Internal_CreateWebCamTexture(deviceName, requestedWidth, requestedHeight, 0);
        }

        public WebCamTexture(string deviceName, int requestedWidth, int requestedHeight, int requestedFPS)
        {
            this.Internal_CreateWebCamTexture(deviceName, requestedWidth, requestedHeight, requestedFPS);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern Color GetPixel(int x, int y);
        public Color[] GetPixels()
        {
            return this.GetPixels(0, 0, this.width, this.height);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern Color[] GetPixels(int x, int y, int blockWidth, int blockHeight);
        public Color32[] GetPixels32()
        {
            Color32[] colors = null;
            return this.GetPixels32(colors);
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern Color32[] GetPixels32(Color32[] colors);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private static extern void INTERNAL_CALL_Pause(WebCamTexture self);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private static extern void INTERNAL_CALL_Play(WebCamTexture self);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private static extern void INTERNAL_CALL_Stop(WebCamTexture self);
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern void Internal_CreateWebCamTexture(string device, int requestedWidth, int requestedHeight, int maxFramerate);
        public void Pause()
        {
            INTERNAL_CALL_Pause(this);
        }

        public void Play()
        {
            INTERNAL_CALL_Play(this);
        }

        public void Stop()
        {
            INTERNAL_CALL_Stop(this);
        }

        public string deviceName { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }

        public static WebCamDevice[] devices { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool didUpdateThisFrame { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool isPlaying { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public float requestedFPS { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }

        public int requestedHeight { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }

        public int requestedWidth { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] set; }

        public int videoRotationAngle { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }
    }
}

